package mock;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.List;

import static org.mockito.Mockito.*;


/**
 * @author by zhangql
 * @Classname MockTest
 * @Description TODO
 * @Date 2021/8/21 8:29
 */

@RunWith(MockitoJUnitRunner.class)
public class MockTest {

    @Test
    public void mockTest() {
         List list = mock(List.class);
        when(list.get(0)).thenReturn("hello mock");
        final String o = (String)list.get(0);
        //校验调用次数
        verify(list).get(0);
        Assert.assertEquals("hello mock",o);
    }

}